﻿<Page x:Class="Wokhan.WindowsFirewallNotifier.Console.UI.Pages.EventsLog"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      DataContext="{Binding RelativeSource={RelativeSource Self}}"
      mc:Ignorable="d" 
      d:DesignHeight="400" d:DesignWidth="800"
	Title="Event log">
    <DockPanel>
        <Border Background="#FFFF7B7B" Style="{StaticResource NonAdminPanel}">
            <WrapPanel>
                <Label Content="Only an administrator can use this feature." />
                <Button x:Name="btnRestartAdmin" Click="btnRestartAdmin_Click">
                    <Grid>
                        <Path Height="16" HorizontalAlignment="Left" Stretch="Uniform" Fill="#FF5353F7" Data="{StaticResource Image_Shield}" />
                        <Label Margin="20,0,0,0" Padding="0" Content="restart as admin" />
                    </Grid>
                </Button>
            </WrapPanel>
        </Border>
        <Border Style="{StaticResource ToolBarPanel}" IsEnabled="{Binding IsElevated,Source={x:Static Application.Current}}">
            <Grid>
                <WrapPanel>
                    <ToggleButton IsChecked="{Binding IsTrackingEnabled}">
                        <Grid>
                            <Path HorizontalAlignment="Left" Height="16" Stretch="Uniform" Fill="Green">
                                <Path.Style>
                                    <Style TargetType="Path">
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding IsTrackingEnabled}" Value="True">
                                                <Setter Property="Data" Value="{StaticResource Image_Stop}" />
                                            </DataTrigger>
                                            <DataTrigger Binding="{Binding IsTrackingEnabled}" Value="False">
                                                <Setter Property="Data" Value="{StaticResource Image_Start}" />
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Path.Style>
                            </Path>
                            <Label Margin="20,0,0,0" Content="Auto-refresh" />
                        </Grid>
                    </ToggleButton>
                    <Button x:Name="btnLocate" Click="btnLocate_Click">
                        <Grid>
                            <Path Fill="CornflowerBlue" Data="{StaticResource Image_Locate}"/>
                            <TextBlock Margin="20,0,0,0" Text="Locate" />
                        </Grid>
                    </Button>
                    <Button x:Name="btnEventLogVwr" Click="btnEventLogVwr_Click">
                        <Grid>
                            <Image Source="/WFN;component/Resources/Images/btnLEvents.Image.png" HorizontalAlignment="Left" Height="16"/>
                            <TextBlock Margin="20,0,0,0" Text="Events log viewer" />
                        </Grid>
                    </Button>
                    <TextBlock VerticalAlignment="Center" Text="{Binding LogEntries.Count, StringFormat='{}{0} item(s)', FallbackValue='No item found'}" />
                </WrapPanel>
                <WrapPanel HorizontalAlignment="Right">
                    <Border BorderBrush="White" Background="White" BorderThickness="0" CornerRadius="8" Padding="5,2" Margin="0,0,5,0">
                        <WrapPanel>
                            <Path Fill="#FFA2A2FF" Data="{StaticResource Image_UpdateRate}"/>
                            <Label Margin="4,0" Content="Update rate:" />
                            <ComboBox IsEditable="False" Width="70" ItemsSource="{Binding Intervals, StringFormat='\{0\}s'}" SelectedValue="{Binding Interval}" />
                        </WrapPanel>
                    </Border>
                    <ToggleButton x:Name="btnHelp">
                        <Path Fill="Chocolate" Data="{StaticResource Image_Help}"/>
                    </ToggleButton>
                </WrapPanel>
            </Grid>
        </Border>
        <Grid IsEnabled="{Binding IsElevated,Source={x:Static Application.Current}}">
            <DataGrid BorderThickness="0" AlternatingRowBackground="Gainsboro" x:Name="gridLog" IsReadOnly="True" ColumnWidth="*" ItemsSource="{Binding LogEntries}" AutoGenerateColumns="True" HeadersVisibility="Column">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="CreationTime" Binding="{Binding CreationTime}"/>
                    <DataGridTemplateColumn Header="Path" SortMemberPath="FriendlyPath">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Grid>
                                    <Image Source="{Binding Icon}" Width="16" HorizontalAlignment="Left"/>
                                    <Label Content="{Binding FriendlyPath}" Margin="20,0,0,0" />
                                </Grid>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTextColumn Header="IP" Binding="{Binding Replacement5}"/>
                    <DataGridTextColumn Header="Protocol" Binding="{Binding Protocol}"/>
                    <DataGridTextColumn Header="Replacement6" Binding="{Binding Replacement6}"/>
                </DataGrid.Columns>
            </DataGrid>
            <Border Style="{StaticResource InfoBlock}">
                <TextBlock>This page displays a list of the latest blocked outgoing connections (for performance reasons, the list has been limited to 500 items). If you need a complete list, please use the Windows events log viewer.</TextBlock>
            </Border>
        </Grid>
    </DockPanel>
</Page>
